package com.tledu.car.controller;

import com.tledu.carLog.domain.CarLog;
import com.tledu.carLog.domain.dto.CarLogDto;
import com.tledu.carLog.service.ICarLogService;
import com.tledu.common.annotation.Log;
import com.tledu.common.core.controller.BaseController;
import com.tledu.common.core.domain.AjaxResult;
import com.tledu.common.core.page.TableDataInfo;
import com.tledu.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 操作日志Controller
 * 
 * @author ruoyi
 * @date 2024-09-02
 */
@RestController
@RequestMapping("/car/log")
public class CarLogController extends BaseController
{
    @Autowired
    private ICarLogService carLogService;

    /**
     * 查询操作日志列表
     */
    @PreAuthorize("@ss.hasPermi('car:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(CarLogDto carLogDto)
    {
        startPage();
        List<CarLogDto> list = carLogService.selectCarLogList(carLogDto);
        return getDataTable(list);
    }

    /**
     * 导出操作日志列表
     */
    // @PreAuthorize("@ss.hasPermi('car:log:export')")
    // @Log(title = "操作日志", businessType = BusinessType.EXPORT)
    // @PostMapping("/export")
    // public void export(HttpServletResponse response, CarLogDto carLogDto)
    // {
    //     List<CarLogDto> list = carLogService.selectCarLogList(carLogDto);
    //     ExcelUtil<CarLog> util = new ExcelUtil<CarLog>(CarLog.class);
    //     util.exportExcel(response, list, "操作日志数据");
    // }

    /**
     * 获取操作日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('car:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(carLogService.selectCarLogById(id));
    }

    @PreAuthorize("@ss.hasPermi('car:log:query')")
    @GetMapping(value = "/getInfo1/{id}")
    public AjaxResult getInfo1(@PathVariable("id") Long id)
    {
        return success(carLogService.selectCarLogById1(id));
    }
    /**
     * 新增操作日志
     */
    @PreAuthorize("@ss.hasPermi('car:log:add')")
    @Log(title = "操作日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CarLog carLog)
    {
        return toAjax(carLogService.insertCarLog(carLog));
    }

    /**
     * 修改操作日志
     */
    @PreAuthorize("@ss.hasPermi('car:log:edit')")
    @Log(title = "操作日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CarLog carLog)
    {
        return toAjax(carLogService.updateCarLog(carLog));
    }

    /**
     * 删除操作日志
     */
    @PreAuthorize("@ss.hasPermi('car:log:remove')")
    @Log(title = "操作日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(carLogService.deleteCarLogByIds(ids));
    }
}
